<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var n = 0;

        function a() {
            var n = 10;

            function b() {
                n++;
                console.log(n);
            }

            function d() {
                n++;
                console.log(n);
            }
            b();
            return d;
        }
        var c = a();
        c();
        console.log(n);
        //c 和 d 用到了同一个地址中的n，所以他们都会改变n的值
        a();
    </script>
</body>

</html>